// 2025/11/7
// 最长公共前缀

class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        int end = 0, n = strs.size(), k = strs[0].size();
        while(end < k)
        {
            for(int i = 1; i < n; i++)
            {
                if(end > strs[i].size() || strs[i][end] != strs[i - 1][end])
                {
                    return strs[0].substr(0, end);
                }
            }
            end++;
        }
        return strs[0].substr(0, k);
    }
};